package com.sgb.zhaocai.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.zhaocai.base.BaseApi;
import com.sgb.zhaocai.entity.FindRuleBean;
import com.sgb.zhaocai.view.activity.PickInvitedSignUpActivity;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.dialog.DialogHelper;

/**
 * Time:2021/12/20
 * AUTHOR:F_Q
 * Description:
 */
public class PickInvitedSignUpModel extends ViewModel {
    PickInvitedSignUpActivity activity;
    public void setActivity(PickInvitedSignUpActivity pickInvitedSignUpActivity) {
        this.activity = pickInvitedSignUpActivity;
    }

    /**
     * 招标规则
     * @param id
     */
    public void findTenderRuleDetail(String id) {
        DialogHelper.showProgressDialog(activity, null, "数据加载中", 0, true, null).setCanceledOnTouchOutside(false);
        BaseApi.getApi().getFindTenderRuleDetail(id).enqueue(new ICallBack<BaseEntity<FindRuleBean>>() {
            @Override
            public void onSuccess(BaseEntity<FindRuleBean> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getState().equals(BaseApi.RESPONSE_OK)){
                    activity.setFindRule(data.getData());
                }
            }
        });
    }

    /**
     * 竞价规则
     * @param id
     */
    public void findBidderRuleDetail(String id) {
        DialogHelper.showProgressDialog(activity, null, "数据加载中", 0, true, null).setCanceledOnTouchOutside(false);
        BaseApi.getApi().getFindBidderRuleDetail(id).enqueue(new ICallBack<BaseEntity<FindRuleBean>>() {
            @Override
            public void onSuccess(BaseEntity<FindRuleBean> data) {
                DialogHelper.dismissProgressDialog();
                if (data.getState().equals(BaseApi.RESPONSE_OK)){
                    activity.setFindRule(data.getData());
                }
            }
        });
    }
}
